<template>
	<view class="content"><mix-tree :list="list" @treeItemClick="treeItemClick"></mix-tree></view>
</template>

<script>
import mixTree from '@/components/mix-tree/mix-tree';
import Global from '@/common/js/chat/config.js';
import Request_1 from '@/common/js/chat/Request.js';

export default {
	components: {
		mixTree
	},
	data() {
		return {
			list: []
		};
	},
	onLoad() {
		var that = this;
		new Request_1.Request(Global.GlobalSocketUser.GetMembers).Then(a => {
			
			that.list.push({
				id: 99999999999,
				name: '我的好友',
				count: 0,
				children: []
			});
			console.log(Global.GlobalSocketUser.GetMembers)

			console.log(JSON.stringify(a.date.projectUserGroupMember))

			for (var i = 0; i < a.date.projectUserGroupMember.length; i++) {
				var item = a.date.projectUserGroupMember[i];

				var parameter = JSON.parse(item.parameter);

				if (item.groupKey) {
				} else {
					that.list[0].children.push({
						id: parameter.userkey,
						name: parameter.userName,
						img: parameter.headImg
					});
					that.list[0].count++;
				}
			}
			
			that.list[0].children.push({
				id: '115',
				name: '健健',
				img: "http://ww2.sinaimg.cn/large/c0b9b2c8jw1epxob2qiwfj20g90g63z2.jpg"
			});
			
			that.list[0].count++;
		});
	},
	methods: {
		//点击最后一级时触发该事件
		treeItemClick(item) {
			
			uni.navigateTo({
				url: '../chat/chat?sesstion=' + item.id + '&userName='+item.name+'&headImg='+item.img
			});
			
			console.log(JSON.stringify(item));
		}
	}
};
</script>

<style></style>
